package ezCall;

import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.BasicEditField;
import net.rim.device.api.ui.component.GaugeField;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.TextField;
import net.rim.device.api.ui.container.DialogFieldManager;
import net.rim.device.api.ui.container.PopupScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;


public class Gauge_PopupScreen 
{
    private PopupScreen _popup;
	private GaugeField  _gaugeField;

	private LabelField _LabelField;
	private BasicEditField _TextField;

	private String _LabelText;
	

	public Gauge_PopupScreen( String Title, int min, int max )
	{
		_LabelField = new LabelField(Title, LabelField.FIELD_HCENTER );
		_LabelText = new String();
		_TextField = new BasicEditField( BasicEditField.NO_EDIT_MODE_INPUT | BasicEditField.NON_FOCUSABLE | BasicEditField.FIELD_HCENTER );
		
		_LabelText = Title;
		
		DialogFieldManager manager = new DialogFieldManager();
        _popup = new PopupScreen(manager);
        _gaugeField = new GaugeField(null, min, max, min, GaugeField.NO_TEXT);
        
        _TextField.setText(Title);
        manager.addCustomField(_LabelField);

        
       // manager.addCustomField(_gaugeField);
	}
	
	
	public void Push_Screen()
	{
		UiApplication.getUiApplication().pushScreen( _popup );
	}
	
	public void Pop_Screen()
	{
		UiApplication.getUiApplication().popScreen( _popup );
	}	
	
	public boolean isDisplayed()
	{
		return _popup.isDisplayed();
	}
	
	public void Set_Value( int Value )
	{
		//_gaugeField.setValue(Value);
		
		String ValueText;
		
		ValueText = _LabelText + Integer.toString( Value );
		
		//_TextField.setText( ValueText );
		_LabelField.setText( ValueText, 0, ValueText.length() );
	}


	public void Set_SafeValue( final int Value )
	{
		UiApplication.getUiApplication().invokeLater(new Runnable() 
		{
	        public void run() 
	        {
	    		//화면에 진행 상황 표시
	    		Set_Value(Value);
	        }
		} ); 
	}	
	
	
	
	
}
